package com.hdl.design.pattern.decorator;

/**
 * 类名 Client
 * 描述 装饰器模式客户端
 *
 * @author hedonglin
 * @version 1.0
 * @date 2019/9/25 10:27
 */
public class Client {
    public static void main(String[] args) {
        // 创建一个添加职责的具体对象
        ConcreteComponent component = new ConcreteComponent();

        // 创建两个装饰器
        ConcreteDecoratorFirst first = new ConcreteDecoratorFirst();
        ConcreteDecoratorSecond second = new ConcreteDecoratorSecond();

        // 将first的具体装饰器设置为component
        first.setComponent(component);
        // 将second的具体装饰器设置为first(也就是说，second是在first装饰完毕的基础上继续装饰)
        second.setComponent(first);

        // 调用second操作
        second.operation();
    }
}
